<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>用药错误事件上报修改表</title>
  <link rel="stylesheet" href="../layui/css/layui.css">
  <script src="../layui/layui.js"></script>
  <style>
    td{
      padding-left: 10px;
      padding-bottom: 5px;
      padding-right: 20px;
      padding-top: 10px;
    }
  </style>
</head>
<body>
<button type="button" class="layui-btn"  id = “back” onclick="self.location = document.referrer;">返回</button>
<form class="layui-form" lay-filter="FormLoad" >
  <table border="1px" width="100%" cellpadding="0">
    <tr >
      <td colspan="6" style="text-align: center; height: 50px"> <span style=" font-size: 20px">药品不良反应/事件报告</span> </td>
    </tr>
    <tr>
      <td colspan="3" style="height: 30px"> <div>
        <input type="radio" name="report_order" value="首次报告" title="首次报告">
        <input type="radio" name="report_order" value="跟踪报告" title="跟踪报告" >
      </div> </td>
      <td colspan="1" style="height: 30px">
        编码
      </td>
      <td colspan="2" style="height: 30px">
        <input type="text" name="code" placeholder="" class="layui-input">
      </td>
    </tr>
    <tr>
      <div class="layui-form-item">
        <td>
          报告类型
        </td>
        <td colspan="2">
          <input type="radio" name="report_type" value="新的" title="新的">
          <input type="radio" name="report_type" value="严重" title="严重">
          <input type="radio" name="report_type" value="一般" title="一般">
        </td>

        <td>
          报告单位类型
        </td>

        <td colspan="2">
          <input type="radio" name="reporter_unit_type" value="医疗机构" title="医疗机构">
          <input type="radio" name="reporter_unit_type" value="经营企业" title="经营企业">
          <input type="radio" name="reporter_unit_type" value="生产企业" title="生产企业">
          <input type="radio" name="reporter_unit_type" value="其他" title="其他">
        </td>
      </div>
    </tr>
    <tr>
      <div class="layui-form-item">
        <td>
          患者姓名
        </td>
        <td>
          <input type="text" name="patient_name" placeholder="" class="layui-input">
        </td>

        <td>
          性别
        </td>

        <td>
          <input type="radio" name="patient_sex" value="男" title="男">
          <input type="radio" name="patient_sex" value="女" title="女">
        </td>
        <td>
          出生日期
        </td>

        <td>
          <input type="text" name="patient_birthday" lay-verify="birth_date" id="birth_date" placeholder="" class="layui-input">
        </td>
      </div>
    </tr>
    <tr>
      <div class="layui-form-item">
        <td>
          民族
        </td>
        <td>
          <input type="text" name="patient_nation" placeholder="" class="layui-input">
        </td>

        <td>
          体重
        </td>

        <td>
          <input type="text" name="patient_weight" placeholder="" class="layui-input">
        </td>
        <td>
          联系方式
        </td>

        <td>
          <input  name="patient_phone" type="tel"  lay-verify="required|phone" class="layui-input">
        </td>
      </div>
    </tr>
    <tr>
      <div class="layui-form-item">
        <td>
          原患疾病
        </td>
        <td>
          <input type="text" name="original_illness" placeholder="" class="layui-input">
        </td>

        <td>
          医院名称
        </td>

        <td>
          <input type="text" name="hospital_name" placeholder="" class="layui-input">
        </td>
        <td>
          既往药品不良反应事件/事件
        </td>

        <td>
          <input type="text" name="original_med_bad_event" placeholder="" class="layui-input">
        </td>
      </div>
    </tr>
    <tr>
      <div class="layui-form-item">
        <td>
          病历号/门诊号
        </td>
        <td>
          <input type="text" name="patient_num" placeholder="" class="layui-input">
        </td>

        <td>
          家族药品不良反应/事件
        </td>

        <td>
          <input type="text" name="family_med__bad_event" placeholder="" class="layui-input">
        </td>
        <td colspan="2">
        </td>
      </div>
    </tr>
    <tr>
      <td colspan="1">
        相关重要信息
      </td>
      <td colspan="5">

        <input type="radio" name="related_important_mes" value="吸烟史" title="吸烟史">
        <input type="radio" name="related_important_mes" value="饮酒史" title="饮酒史">
        <input type="radio" name="related_important_mes" value="妊娠期" title="妊娠期">
        <input type="radio" name="related_important_mes" value="肝病史" title="肝病史">
        <input type="radio" name="related_important_mes" value="肾病史" title="肾病史">
        <input type="radio" name="related_important_mes" value="过敏史" title="过敏史">
        <input type="radio" name="related_important_mes" value="其他" title="其他">
      </td>

    </tr>
    <tr>
      <div class="layui-form-item">
        <td colspan="6" style="height: 50px">
          药品
        </td>
      </div>
    </tr>
    <tr>
      <div class="layui-form-item">
        <td colspan="1">
          怀疑药品
        </td>
        <td colspan="5">
          <textarea name="doubt_med" style="height: 100px" required lay-verify="required" placeholder="请输入" class="layui-textarea"></textarea>
        </td>
      </div>
    </tr>
    <tr>
      <div class="layui-form-item">
        <td colspan="1">
          并用药品
        </td>
        <td colspan="5">
          <textarea name="unit_med" style="height: 100px" required lay-verify="required" placeholder="请输入" class="layui-textarea"></textarea>
        </td>
      </div>
    </tr>
    <tr>
      <div class="layui-form-item">
        <td colspan="1">
          不良反应/事件名称
        </td>
        <td colspan="2">
          <input type="text" name="bad_event_name" placeholder="" class="layui-input">
        </td>
        <td colspan="1">
          不良反应/事件发生时间
        </td>
        <td colspan="2">
          <input type="text" name="bad_event_happen_time" id="bad_time" placeholder="" class="layui-input">
        </td>
      </div>
    </tr>
    <tr style="font-size: 20px">
      <div class="layui-form-item">
        <td colspan="6">
          不良反应/事件过程描述(包括症状，体征，临床检验)及处理情况（可附页）
        </td>
      </div>
    </tr>
    <tr>
      <div class="layui-form-item">
        <td colspan="6">
          <textarea name="bad_event_process" style="height: 100px" required lay-verify="required" placeholder="请输入" class="layui-textarea"></textarea>
        </td>
      </div>
    </tr>
    <tr>
      <div class="layui-form-item">
        <td colspan="1">
          不良反应事件的结果
        </td>
        <td colspan="5">
          <input type="radio" name="bad_event_result" value="治愈" title="治愈">
          <input type="radio" name="bad_event_result" value="好转" title="好转">
          <input type="radio" name="bad_event_result" value="未好转" title="未好转">
          <input type="radio" name="bad_event_result" value="不详" title="不详">
          <input type="radio" name="bad_event_result" value="有后遗症" title="有后遗症">
          <input type="radio" name="bad_event_result" value="死亡" title="死亡">
        </td>
      </div>
    </tr>
    <tr>
      <div class="layui-form-item">
        <td colspan="1">
          若有后遗症表现：
        </td>
        <td colspan="1">
          <input type="text" name="sequel_expression"  placeholder="" class="layui-input">
        </td>
        <td colspan="1">
          若死亡直接死因：
        </td>
        <td colspan="1">
          <input type="text" name="death_direct_reason"  placeholder="" class="layui-input">
        </td>
        <td colspan="1">
          死亡时间：
        </td>
        <td colspan="1">
          <input type="text" name="death_time" id="death_time" placeholder="" class="layui-input">
        </td>
      </div>

    <tr>
      <div class="layui-form-item">
        <td colspan="2">
          停药或减药后，反应/事件是否消失或减轻：
        </td>
        <td colspan="4">
          <input type="radio" name="bad_event_change" value="是" title="是">
          <input type="radio" name="bad_event_change" value="否" title="否">
          <input type="radio" name="bad_event_change" value="不明" title="不明">
          <input type="radio" name="bad_event_change" value="未减药或未停药" title="未减药或未停药">
        </td>
      </div>
    </tr>
    <tr>
      <td colspan="2">
        再次使用可疑药品后是否再次出现同样反应/事件
      </td>
      <td colspan="4">
        <input type="radio" name="bad_event_alike_happen" value="是" title="是">
        <input type="radio" name="bad_event_alike_happen" value="否" title="否">
        <input type="radio" name="bad_event_alike_happen" value="不明" title="不明">
        <input type="radio" name="bad_event_alike_happen" value="未在使用" title="未在使用">
      </td>
    </tr>
    <tr>
      <td colspan="2">
        对原患疾病的影响
      </td>
      <td colspan="4">
        <input type="radio" name="original_illness_influence" value="不明显" title="不明显">
        <input type="radio" name="original_illness_influence" value="病程延长" title="病程延长">
        <input type="radio" name="original_illness_influence" value="病情加重" title="病情加重">
        <input type="radio" name="original_illness_influence" value="导致后遗症" title="导致后遗症">
        <input type="radio" name="original_illness_influence" value="导致死亡" title="导致死亡">
      </td>
    <tr>
      <td rowspan="2">
        关联性评价
      </td>
      <td colspan="1">
        报告人评价
      </td>
      <td colspan="2">
        <input type="radio" name="reporter_appraise" value="可能" title="可能">
        <input type="radio" name="reporter_appraise" value="可能无关" title="可能无关">
        <input type="radio" name="reporter_appraise" value="待评价" title="待评价">
        <input type="radio" name="reporter_appraise" value="无法评价" title="无法评价">
      </td>
      <td colspan="1">
        签名
      </td>
      <td colspan="1">
        <input type="text" name="reporter_appraise_sign"  placeholder="" class="layui-input">
      </td>
    </tr>
    <tr>
      <td colspan="1">
        报告人单位评价
      </td>
      <td colspan="2">

        <input type="radio" name="reporter_unit_appraise" value="肯定" title="肯定">
        <input type="radio" name="reporter_unit_appraise" value="很可能" title="很可能">
        <input type="radio" name="reporter_unit_appraise" value="可能" title="可能">
        <input type="radio" name="reporter_unit_appraise" value="可能无关" title="可能无关">
        <input type="radio" name="reporter_unit_appraise" value="待评价" title="待评价">
        <input type="radio" name="reporter_unit_appraise" value="无法评价" title="无法评价">
      </td>
      <td colspan="1">
        签名
      </td>
      <td colspan="1">
        <input type="text" name="reporter_unit_appraise_sign"  placeholder="" class="layui-input">
      </td>
    </tr>
    <tr>
      <td rowspan="2">
        报告人信息
      </td>
      <td colspan="1">
        联系电话
      </td>
      <td colspan="1">
        <input type="text" name="reporter_phone"  lay-verify="required|phone" placeholder="" class="layui-input">
      </td>
      <td colspan="1">
        职业
      </td>
      <td colspan="2">
        <input type="radio" name="reporter_profession" value="医生" title="医生">
        <input type="radio" name="reporter_profession" value="药师" title="药师">
        <input type="radio" name="reporter_profession" value="护士" title="护士">
        <input type="radio" name="reporter_profession" value="其他" title="其他">
      </td>
    </tr>
    <tr>
      <td colspan="1">
        电子邮箱
      </td>
      <td colspan="1">
        <input type="text" name="reporter_email"  placeholder="" lay-verify="required|email" class="layui-input">
      </td>
      <td colspan="1">
        签名
      </td>
      <td colspan="2">
        <input type="text" name="reporter_sign"  placeholder="" class="layui-input">
      </td>
    </tr>

    <tr>
      <td rowspan="2">
        报告单位信息
      </td>
      <td colspan="1">
        单位名称
      </td>
      <td colspan="1">
        <input type="text" name="reporter_unit_name"  placeholder="" class="layui-input">
      </td>
      <td colspan="1">
        联系人
      </td>
      <td colspan="2">
        <input type="text" name="reporter_unit_contact"  placeholder="" class="layui-input">
      </td>
    </tr>
    <tr>
      <td colspan="1">
        电话
      </td>
      <td colspan="1">
        <input type="text" name="reporter_unit_contact_phone"  placeholder="" class="layui-input">
      </td>
      <td colspan="1">
        报告日期
      </td>
      <td colspan="2">
        <input type="text" name="report_date" id="report_date" placeholder="" class="layui-input">
      </td>
    </tr>
    <tr>
      <td colspan="1">
        生产企业请填写信息来源
      </td>
      <td colspan="5">
        <input type="radio" name="mes_source" value="医疗机构" title="医疗机构">
        <input type="radio" name="mes_source" value="经营企业" title="经营企业">
        <input type="radio" name="mes_source" value="个人" title="个人">
        <input type="radio" name="mes_source" value="文献报道" title="文献报道">
        <input type="radio" name="mes_source" value="上市后研究" title="上市后研究">
        <input type="radio" name="mes_source" value="其他" title="其他">
      </td>
    </tr>
    <tr>
      <td colspan="1">
        备注
      </td>
      <td colspan="5">
        <input type="text" name="remarks"  placeholder="" class="layui-input">
      </td>
    </tr>
  </table>
  <div class="layui-form-item">
    <div class="layui-input-block" style="text-align: center; margin-top: 50px">
      <button class="layui-btn" lay-submit lay-filter="save1">暂存</button>
      <button class="layui-btn" lay-submit lay-filter="save2">提交</button>
    </div>
  </div>
</form>

</body>

<script>

  let str;
  layui.use(['laydate','jquery','form','layedit','layer','table','laytpl'], function() {
    let $ = layui.jquery;
    let form = layui.form;
    let laydate = layui.laydate;
    var layer = layui.layer;
    var router = layui.router();
    laydate.render({
      elem: '#reporter_know_time' //指定元素
      , type: 'date'
    });
    laydate.render({
      elem: '#event_happen_time' //指定元素
      , type: 'date'
    });

    function getQueryVariable(variable)
    {
      let query = window.location.search.substring(1);
      let vars = query.split("&");
      for (let i=0;i<vars.length;i++) {
        let pair = vars[i].split("=");
        if(pair[0] == variable){return pair[1];}
      }
      return(false);
    }

    form.render();
    // 获取地址的中的值
    let form_code=getQueryVariable("form_code");
    console.log(form_code);
    $.ajax({
      url: '/look?form_code=' + form_code,
      type: 'get',
      success: function (data) {
        //console.log(data);
        let jsonObj = eval('(' + data + ')'); //获得jsonObj对象
        //console.log(jsonObj);
        //渲染 上报人和上报人单位
        let json = {};
        for(let i = 0; i<jsonObj.data.length; i++) {
          json[jsonObj.data[i].property_en_name] = jsonObj.data[i].detailed_data;
        }
        //console.log(json);
        form.val("FormLoad",json)
      }
    });

    form.on('submit(save1)', function (data) {
      layer.confirm('确定暂存吗？', {
        btn: ['确认', '取消'] //按钮
      }, function () {
        let json = {
          "form_code": form_code,
          "report_order":data.field.report_order,
          "code":data.field.code,
          "report_type":data.field.report_type,
          "reporter_unit_type":data.field.reporter_unit_type,
          "patient_name":data.field.patient_name,
          "patient_sex":data.field.patient_sex,
          "patient_birthday":data.field.patient_birthday,
          "patient_nation":data.field.patient_nation,
          "patient_weight":data.field.patient_weight,
          "patient_phone":data.field.patient_phone,
          "original_illness":data.field.original_illness,
          "hospital_name":data.field.hospital_name,
          "original_med_bad_event":data.field.original_med_bad_event,
          "patient_num":data.field.patient_num,
          "family_med__bad_event":data.field.family_med__bad_event,
          "doubt_med":data.field.doubt_med,
          "unit_med":data.field.unit_med,
          "bad_event_name":data.field.bad_event_name,
          "bad_event_happen_time":data.field.bad_event_happen_time,
          "bad_event_process":data.field.bad_event_process,
          "related_important_mes":data.field.related_important_mes,
          "bad_event_result":data.field.bad_event_result,
          "sequel_expression":data.field.sequel_expression,
          "death_direct_reason":data.field.death_direct_reason,
          "death_time":data.field.death_time,
          "bad_event_change":data.field.bad_event_change,
          "bad_event_alike_happen":data.field.bad_event_alike_happen,
          "original_illness_influence":data.field.original_illness_influence,
          "reporter_appraise":data.field.reporter_appraise,
          "reporter_appraise_sign":data.field.reporter_appraise_sign,
          "reporter_unit_appraise":data.field.reporter_unit_appraise,
          "reporter_unit_appraise_sign":data.field.reporter_unit_appraise_sign,
          "reporter_phone":data.field.reporter_phone,
          "reporter_profession":data.field.reporter_profession,
          "reporter_email":data.field.reporter_email,
          "reporter_sign":data.field.reporter_sign,
          "reporter_unit_name":data.field.reporter_unit_name,
          "reporter_unit_contact":data.field.reporter_unit_contact,
          "reporter_unit_contact_phone":data.field.reporter_unit_contact_phone,
          "report_date":data.field.report_date,
          "mes_source":data.field.mes_source,
          "remarks":data.field.remarks,
          "status":1 //暂存
        };

        $.ajax({
          url: '/event/event_update',
          type: "POST",
          data: json,
          success: function (index) {
            layer.msg("修改成功");
            self.location = document.referrer;
          }
        })

      }, function () {
        self.location = document.referrer;
      });
      return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
    });

    form.on('submit(save2)', function (data) {

      layer.confirm('确定提交吗？', {
        btn: ['确认', '取消'] //按钮
      }, function () {
        let json = {
          "form_code": form_code,
          "report_order":data.field.report_order,
          "code":data.field.code,
          "report_type":data.field.report_type,
          "reporter_unit_type":data.field.reporter_unit_type,
          "patient_name":data.field.patient_name,
          "patient_sex":data.field.patient_sex,
          "patient_birthday":data.field.patient_birthday,
          "patient_nation":data.field.patient_nation,
          "patient_weight":data.field.patient_weight,
          "patient_phone":data.field.patient_phone,
          "original_illness":data.field.original_illness,
          "hospital_name":data.field.hospital_name,
          "original_med_bad_event":data.field.original_med_bad_event,
          "patient_num":data.field.patient_num,
          "family_med__bad_event":data.field.family_med__bad_event,
          "doubt_med":data.field.doubt_med,
          "unit_med":data.field.unit_med,
          "bad_event_name":data.field.bad_event_name,
          "bad_event_happen_time":data.field.bad_event_happen_time,
          "bad_event_process":data.field.bad_event_process,
          "related_important_mes":data.field.related_important_mes,
          "bad_event_result":data.field.bad_event_result,
          "sequel_expression":data.field.sequel_expression,
          "death_direct_reason":data.field.death_direct_reason,
          "death_time":data.field.death_time,
          "bad_event_change":data.field.bad_event_change,
          "bad_event_alike_happen":data.field.bad_event_alike_happen,
          "original_illness_influence":data.field.original_illness_influence,
          "reporter_appraise":data.field.reporter_appraise,
          "reporter_appraise_sign":data.field.reporter_appraise_sign,
          "reporter_unit_appraise":data.field.reporter_unit_appraise,
          "reporter_unit_appraise_sign":data.field.reporter_unit_appraise_sign,
          "reporter_phone":data.field.reporter_phone,
          "reporter_profession":data.field.reporter_profession,
          "reporter_email":data.field.reporter_email,
          "reporter_sign":data.field.reporter_sign,
          "reporter_unit_name":data.field.reporter_unit_name,
          "reporter_unit_contact":data.field.reporter_unit_contact,
          "reporter_unit_contact_phone":data.field.reporter_unit_contact_phone,
          "report_date":data.field.report_date,
          "mes_source":data.field.mes_source,
          "remarks":data.field.remarks,
          "status":2 //递交
        };
        console.log(json);
        console.log("123");

        $.ajax({
          url: '/event/event_update',
          type: "POST",
          data: json,
          success: function (index) {
            layer.msg("修改成功");
            self.location = document.referrer;
          }
        })

      }, function () {
      });
      return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
    });

  })
</script>

</html>